var path = require('path')
var webpack = require('webpack')

module.exports = {
	entry: './src/main.js',
	output: {
		path: path.resolve(__dirname, './dist'),
		publicPath: '/dist/',
		filename: 'build.js'
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				use: ['vue-style-loader','css-loader'],
			},{
				test: /\.vue$/,
				loader: 'vue-loader',
				options: {
					loaders: {
					}
					// other vue-loader options go here
				}
			},{
				test: /\.js$/,
				loader: 'babel-loader',
				exclude: /node_modules/
			},
			{
			test: /\.(png|jpg|gif|svg)$/,
			loader: 'file-loader',
			options: {
				name: '[name].[ext]?[hash]'
			}
			},
			//添加less-loader
			{
			test:/\.less$/,
			loader:'vue-style-loader!css-loader!less-loader'
			},
			{
			test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
			loader: 'file-loader'
			},{

			test: /\.(s[ac]ss)$/i,
			use: [
				{
				loader: "style-loader" //没有style-loader，这样写独立的scss文件会报错，实际上参照css部分写就可以啦
				},
				{
				loader: "css-loader",
				options: {           
					modules: {
					localIdentName: '[name]__[local]--[hash:base64:5]'
					},  
				}
				},
				{
				loader: 'sass-loader',
				}
			]
			}
		]
	},
	resolve: {
		alias: { 'vue$': 'vue/dist/vue.esm.js'},
		extensions: ['*', '.js', '.vue', '.json']
	},
	devServer: {
		historyApiFallback: true,
		host: '192.168.13.5',
		noInfo: true,
		overlay: true
	},
	performance: {
		hints: false
	},
	devtool: '#eval-source-map'
	}

	if (process.env.NODE_ENV === 'production') {
	module.exports.devtool = '#source-map'
	// http://vue-loader.vuejs.org/en/workflow/production.html
	module.exports.plugins = (module.exports.plugins || []).concat([
	new webpack.DefinePlugin({
		'process.env': {
		NODE_ENV: '"production"'
		}
	}),
	new webpack.optimize.UglifyJsPlugin({
		sourceMap: true,
		compress: {
		warnings: false
		}
	}),
	new webpack.LoaderOptionsPlugin({
		minimize: true
	})
	])
}
